package com.sg.service.biz.component.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.component.req.ImplementNumericalAccuracyProcessingComReqDto;
import com.sg.dto.biz.component.req.ImplementNumericalAccuracyProcessingReqDto;
import com.sg.dto.biz.component.res.ImplementNumericalAccuracyProcessingComRespDto;
import com.sg.dto.biz.component.res.ImplementNumericalAccuracyProcessingRespDto;
import com.sg.service.base.component.MCustomFields3Service;
import com.sg.service.biz.component.nb.NbBusinessInterfaceMode;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class BusinessInterfaceModeServiceImpl
        implements com.wicket.okrcomponent.biz.service.BusinessInterfaceModeService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MCustomFields3Service mCustomFields3Service;
    @Resource
    private NbBusinessInterfaceMode nbBusinessInterfaceMode;

    /**
     * D2执行数值精度处理(公共)[9447]
     * gen by moon at 4/26/2024, 2:22:33 PM
     */
    @Trace(operationName = "D2执行数值精度处理(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ImplementNumericalAccuracyProcessingComRespDto implementNumericalAccuracyProcessingCom(ImplementNumericalAccuracyProcessingComReqDto reqDto) {


        ImplementNumericalAccuracyProcessingRespDto numericalAccuracyProcessingRes_1 = null;
//步骤0: M2执行数值精度处理（特殊方法） - implementNumericalAccuracyProcessing
        //ModelCode: numericalAccuracyProcessing
        ImplementNumericalAccuracyProcessingRespDto numericalAccuracyProcessingRes = null;
        ImplementNumericalAccuracyProcessingReqDto numericalAccuracyProcessingReq = new ImplementNumericalAccuracyProcessingReqDto();
        if (reqDto != null) {
            numericalAccuracyProcessingReq.setComFloatField(reqDto.getComFloatField());//SimpleFieldAssign//sourceId:1754815_1
            numericalAccuracyProcessingReq.setDecimalPointRules(reqDto.getDecimalPointRules());//SimpleFieldAssign//sourceId:1754816_1
            numericalAccuracyProcessingReq.setDecimalDigitsLastRules(reqDto.getDecimalDigitsLastRules());//SimpleFieldAssign//sourceId:1754817_1
        }

        /*M2执行数值精度处理（特殊方法）[9448]   */
        Assert.isNull(numericalAccuracyProcessingReq.getComFloatField(), "D2执行数值精度处理(公共)-M2执行数值精度处理（特殊方法）-通用数值字段（小数型）不能为空", false);
        Assert.isNull(numericalAccuracyProcessingReq.getDecimalPointRules(), "D2执行数值精度处理(公共)-M2执行数值精度处理（特殊方法）-小数点规则不能为空", false);
        Assert.isNull(numericalAccuracyProcessingReq.getDecimalDigitsLastRules(), "D2执行数值精度处理(公共)-M2执行数值精度处理（特殊方法）-小数最后一位规则不能为空", false);
        numericalAccuracyProcessingRes = nbBusinessInterfaceMode.implementNumericalAccuracyProcessing(numericalAccuracyProcessingReq);


        numericalAccuracyProcessingRes_1 = numericalAccuracyProcessingRes;

        ImplementNumericalAccuracyProcessingComRespDto retData = new ImplementNumericalAccuracyProcessingComRespDto();
        if (numericalAccuracyProcessingRes_1 != null) {
            retData.setComFloatField(numericalAccuracyProcessingRes_1.getComFloatField());//SimpleFieldAssign//sourceId:1754822_1
        }


        return retData;
    }
    //
}
